uniform float4x4 StateComplete;
sampler2D colorMap;
sampler2D depthMap;
float focusDepth = 0.5;
float2 pixelStep = { 0.5, 0.0 };
float ramp = 95;
float exponent = 4;

void vsMain(
			in float4 pos: POSITION,
			out float4 opos: POSITION,
			in float2 tc: TEXCOORD,
			out float2 otc: TEXCOORD
			)
{
	opos = mul(StateComplete, pos);
	otc = tc;
}

float4 psMain(
			  in float2 tc: TEXCOORD
			  ): COLOR
{
	float depth = tex2D(depthMap, tc).x;	
	float blur = min(2,pow(abs(depth-focusDepth)*ramp,exponent));
	float4 c = 0.0;
	c += tex2D(colorMap, tc-pixelStep*3*blur);
	c += tex2D(colorMap, tc-pixelStep*blur)*2;	
	c += tex2D(colorMap, tc+pixelStep*blur)*2;
	c += tex2D(colorMap, tc+pixelStep*3*blur);
	return c / 6.0f;
}